package cn.iocoder.yudao.module.nginxui.dal.mysql.httpserver;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.nginxui.dal.dataobject.httpconfig.HttpConfigDO;
import cn.iocoder.yudao.module.nginxui.dal.dataobject.httpserver.HttpServerDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.nginxui.controller.admin.httpserver.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * Nginx HTTP下的Server块配置 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface HttpServerMapper extends BaseMapperX<HttpServerDO> {

    default PageResult<HttpServerDO> selectPage(HttpServerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HttpServerDO>()
                .eqIfPresent(HttpServerDO::getHttpId, reqVO.getHttpId())
                .eqIfPresent(HttpServerDO::getListen, reqVO.getListen())
                .likeIfPresent(HttpServerDO::getServerName, reqVO.getServerName())
                .eqIfPresent(HttpServerDO::getRoot, reqVO.getRoot())
                .eqIfPresent(HttpServerDO::getIndexFile, reqVO.getIndex())
                .eqIfPresent(HttpServerDO::getSslCertificate, reqVO.getSslCertificate())
                .eqIfPresent(HttpServerDO::getSslCertificateKey, reqVO.getSslCertificateKey())
                .eqIfPresent(HttpServerDO::getExtraServerConfig, reqVO.getExtraServerConfig())
                .eqIfPresent(HttpServerDO::getSort, reqVO.getSort())
                .eqIfPresent(HttpServerDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(HttpServerDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HttpServerDO::getId));
    }
    List<HttpServerDO> selectByHttpIdAndStatus(
            @Param("httpId") Long httpId,
            @Param("status") Integer status
    );
}